<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/3/27
  Time: 22:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>电影信息修改页面</title>
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css"></link>
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css"></link>
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
    <script type="text/javascript">




        function submitData(){
            $("#fm").form("submit",{
                url:"/bssp/movie/updateById",
                onSubmit:function(){
                    var detail= CKEDITOR.instances.detail.getData()
                    if(detail==""){
                        $.messager.alert("系统提示","内容不能为空！");
                        return false;
                    }
                    return $(this).form("validate");
                },
                success:function(result){
                    var result=eval('('+result+')');
                    if(result.success){
                        $.messager.alert("系统提示","保存成功");
                        resetValue();
                    }else{
                        $.messager.alert("系统提示","保存失败");
                        return;
                    }
                }
            });

        }


        function resetValue(){
            $("#name").val("");
            $("#summary").val("");
            $("#imageFile").val("");
            $("#no").prop("checked", true);
            CKEDITOR.instances.detail.setData("");
        }

    </script>
</head>
<body style="margin: 10px">
<div id="p" class="easyui-panel" title="修改电影" style="padding: 10px">
    <form id="fm" method="post" enctype="multipart/form-data">
        <table cellspacing="20px">
            <tr>
                <td width="80px">电影名称：</td>
                <td><input type="text" id="name" name="name" style="width: 400px;" class="easyui-validatebox" required="true"/></td>
            </tr>
            <tr>
                <td width="80px">概括：</td>
                <td><input type="text" id="summary" name="summary" style="width: 400px;" class="easyui-validatebox" required="true"/></td>
            </tr>
            <tr>
                <td width="80px" valign="top">电影图片：</td>
                <td>
                    <input type="hidden" id="imgSrc" name="imgSrc" />
                    <input type="file" id="imageFile" name="imageFile" />
                </td>
            </tr>
            <tr>
                <td width="80px">设置热门：</td>
                <td><input type="radio" id="yes" value="1" name="hotFlag" />是&nbsp;<input type="radio" id="no" value="0"  name="hot" />否</td>
            </tr>
            <tr>
                <td valign="top">内容：</td>
                <td>
                    <textarea name="detail" id="detail" rows="30" cols="80"></textarea>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="hidden" id="id" name="id" />
                    <a href="javascript:submitData()" class="easyui-linkbutton" data-options="iconCls:'icon-submit'">发布</a>
                </td>
            </tr>
        </table>
    </form>
</div>

<script>
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
    CKEDITOR.replace( 'detail' );

    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var url=decodeURI(decodeURI(window.location.search))
        var r = url.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }


    var id=getQueryString("id");;
    $.post("/bssp/movie/findById",{id:id},function(result){
        $("#id").val(result.id);
        $("#name").val(result.name);
        $("#summary").val(result.summary);
        $("#imgSrc").val(result.imgSrc);
        if(result.hotFlag==1){
            $("#yes").prop("checked", true);
        }else{
            $("#no").prop("checked", true);
        }
        CKEDITOR.instances.detail.setData(result.detail);
    },"json");

</script>
</body>
</body>
</html>
